<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <script src="vue.js"></script>
</head>
<body>
  <div id="app">
    <h1>当前记数:{{counter}}</h1>
<!--    <button v-on:click="counter++">+</button>-->
<!--    <button v-on:click="counter&#45;&#45;">-</button>-->
    <button @click="add">+ add</button>
    <button @click="sub">- sub</button>
  </div>
  <script>
    let obj={counter:0};
    const vm=new Vue({
      el:'#app',
      data:obj,
      methods:{
        add(){
          this.counter++
        },
        sub(){
          this.counter--
        }
      }
    })
  </script>
</body>
</html>